<?
if($_SESSION['is_login'] != 1) {    
    header( 'Location:' . fwUrl("login"));
}
dbConnect();
require_once 'page/__header.php';
?>

<div class="controlBar">
	<? if(strlen($_SESSION['e']) > 0) { ?>
    <div id="lnkBackToModule" onclick="do__moduleExit()" class="controlBarButtonLeft shadowMe2">BACK</div>
    
    <div id="" class="controlBarButtonLeft controlBarButtonActive shadowMe2">
    	<?=$_SESSION['e']?>
    </div>
    <? } ?>
    <div id="lnkLogout" onclick="do__logout()" class="controlBarButton shadowMe2">LOGOUT</div>
</div>

<?
if(strlen($_SESSION['e']) > 0) {
	
	$page = 'page/manage/' . $_SESSION['e'] . '.php';
	if(file_exists($page)){
		require_once $page;
	} else {
		$_SESSION['e'] = "";
		require_once 'page/__module.php';
	}
	
} else {
	require_once 'page/__module.php';	
}	

?>


<script language="JavaScript" type="text/javascript">

    $(document).ready(function(){             
        
    });
    
    function do__module(e){    	
    	var url = "<?=getPage("domodule")?>";		
		
		$.post(url, { "e" : e }, function(json) {		    
		    if(json.result && json.result == 1){
			    window.setTimeout("location.reload(true)", 100);			
			}
		}, "json");
    }
    
    function do__moduleExit(){
    	var url = "<?=getPage("domodule")?>";		
		
		$.post(url, { "e" : "" }, function(json) {		    
		    if(json.result && json.result == 1){
			    window.setTimeout("location.reload(true)", 100);			
			}
		}, "json");
    }
    
    function do__logout() {
        
        var url = "<?=getPage("dologout")?>";
        
        $.post(url, { "logout" : "" }, function(json) {    
        
            if(json.result && json.result == 1){
                window.setTimeout("location.reload(true)", 100);
            }
        });
    }
    
</script>

<? require_once 'page/__footer.php'; ?>